package com.qiang.test01;

import java.io.FileOutputStream;
import java.io.IOException;

public class Demo08 {
    public static void main(String[] args) {
        /*
        异常处理
         */
        //try-catch-finally
        FileOutputStream pf = null;
        try {
            //System.out.println(2 / 0);
            pf = new FileOutputStream("day12\\aa.txt");
            byte[] b = {99, 120, 122};
            pf.write(b);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            //不管怎么样，都得执行关闭资源
            //爆红是执行范围
            if (pf != null) {
                try {
                    pf.close();
                    pf = null;
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }

        }
    }
}
